package com.ruoyi.course.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.course.domain.EqAttendanceRecord;
import com.ruoyi.course.service.IEqAttendanceRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司打卡模块-考勤记录数据Controller
 * 
 * @author ruoyi
 * @date 2025-11-01
 */
@RestController
@RequestMapping("/mapper.course/record")
public class EqAttendanceRecordController extends BaseController
{
    @Autowired
    private IEqAttendanceRecordService eqAttendanceRecordService;

    /**
     * 查询公司打卡模块-考勤记录数据列表
     */
    @GetMapping("/list")
    public TableDataInfo list(EqAttendanceRecord eqAttendanceRecord)
    {
        startPage();
        List<EqAttendanceRecord> list = eqAttendanceRecordService.selectEqAttendanceRecordList(eqAttendanceRecord);
        return getDataTable(list);
    }

    /**
     * 导出公司打卡模块-考勤记录数据列表
     */
    @PreAuthorize("@ss.hasPermi('mapper.course:record:export')")
    @Log(title = "公司打卡模块-考勤记录数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EqAttendanceRecord eqAttendanceRecord)
    {
        List<EqAttendanceRecord> list = eqAttendanceRecordService.selectEqAttendanceRecordList(eqAttendanceRecord);
        ExcelUtil<EqAttendanceRecord> util = new ExcelUtil<EqAttendanceRecord>(EqAttendanceRecord.class);
        util.exportExcel(response, list, "公司打卡模块-考勤记录数据数据");
    }

    /**
     * 获取公司打卡模块-考勤记录数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('mapper.course:record:query')")
    @GetMapping(value = "/{attendanceId}")
    public AjaxResult getInfo(@PathVariable("attendanceId") String attendanceId)
    {
        return success(eqAttendanceRecordService.selectEqAttendanceRecordByAttendanceId(attendanceId));
    }

    /**
     * 新增公司打卡模块-考勤记录数据
     */
    @PreAuthorize("@ss.hasPermi('mapper.course:record:add')")
    @Log(title = "公司打卡模块-考勤记录数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EqAttendanceRecord eqAttendanceRecord)
    {
        return toAjax(eqAttendanceRecordService.insertEqAttendanceRecord(eqAttendanceRecord));
    }

    /**
     * 修改公司打卡模块-考勤记录数据
     */
    @PreAuthorize("@ss.hasPermi('mapper.course:record:edit')")
    @Log(title = "公司打卡模块-考勤记录数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EqAttendanceRecord eqAttendanceRecord)
    {
        return toAjax(eqAttendanceRecordService.updateEqAttendanceRecord(eqAttendanceRecord));
    }

    /**
     * 删除公司打卡模块-考勤记录数据
     */
    @PreAuthorize("@ss.hasPermi('mapper.course:record:remove')")
    @Log(title = "公司打卡模块-考勤记录数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{attendanceIds}")
    public AjaxResult remove(@PathVariable String[] attendanceIds)
    {
        return toAjax(eqAttendanceRecordService.deleteEqAttendanceRecordByAttendanceIds(attendanceIds));
    }

    /**
     * 统计指定月份的打卡数据
     */
    @GetMapping("/statistics/{Date}")
    public AjaxResult statistics(@PathVariable String Date)
        {
            return success(eqAttendanceRecordService.statistics(Date));
        }
}
